﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace RMS.Utils.Dicom.Commen
{
    class StreamFile
    {
        private static string _filePath;
        public static String FilePath { set { _filePath = value; } }
        private static Stream _stream;
        public static Stream stream
        {
            get
            {
                if (_stream != null)
                    return _stream;
                else
                    return GetFileStream();
            }
        }

        public static Boolean IsDicomFile()
        {
            _stream = File.OpenRead(_filePath);
            _stream.Position = 128;
            byte[] buffer = new byte[4];
            stream.Read(buffer, 0, 4);
            return  buffer.GetString().Equals(Constants.DicomPrefix) ;
        }

        private static Stream GetFileStream()
        {
            _stream = File.OpenRead(_filePath);
            _stream.Position = 132;
            return _stream;
        }

        public static byte[] Read(int count)
        {
            byte[] buffer = new byte[count];
            stream.Read(buffer, 0, count);
            return buffer;
        }

        private static byte[] pixelData;
        public static byte[] PixelData
        {
            get
            {
                return pixelData;
            }
            set { pixelData = value; }
        }

        private static bool isPixelData = false;
        public static bool IsPixelData
        {
            get
            {
                return isPixelData;
            }
            set { isPixelData = value; }
        }


    }
}
